#include "tools.h"




class Solution {
public:
    ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
        ListNode headpre;
        ListNode* p = &headpre;
        while (l1 != nullptr && l2 != nullptr){
            if (l1->val <= l2->val){
                p->next = l1;
                l1 = l1->next;
            }else{
                p->next = l2;
                l2 = l2->next;
            }
            p = p->next;
        }
        if (l1 != nullptr) p->next = l1;
        if (l2 != nullptr) p->next = l2;
        return headpre.next;
    }
};


int main(int argc, char const *argv[])
{
    ListNode * l1 = simple_list();
    ListNode * l2 = simple_list_2();
    show(l1);
    show(l2);

    Solution s;
    ListNode* p = s.mergeTwoLists(l1, l2);

    show(p);
    return 0;
}
